home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 December / 2004-12 CHIP.iso / CHIP / Porady / Srodowisko PHP-MySQL / ACTIVESTATE PERL ADD-ON / PERL_add-on.exe / {app} / perl / bin / XMLRPCsh.bat < prev    next >
DOS Batch File  |  2004-06-01  |  3KB  |  95 lines

  1. @rem = '--*-Perl-*--
  2. @echo off
  3. if "%OS%" == "Windows_NT" goto WinNT
  4. perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
  5. goto endofperl
  6. :WinNT
  7. perl -x -S %0 %*
  8. if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
  9. if %errorlevel% == 9009 echo You do not have Perl in your PATH.
  10. if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
  11. goto endofperl
  12. @rem ';
  13. #!/bin/env perl 
  14. #line 15
  15. #!d:\perl\bin\perl.exe 
  16.  
  17. # -- XMLRPC::Lite -- soaplite.com -- Copyright (C) 2001 Paul Kulchenko --
  18.  
  19. use strict;
  20. use XMLRPC::Lite;
  21. use Data::Dumper; $Data::Dumper::Terse = 1; $Data::Dumper::Indent = 1;
  22.  
  23. @ARGV or die "Usage: $0 endpoint [commands...]\n";
  24. my $proxy = shift;
  25. my %can;
  26. my $xmlrpc = XMLRPC::Lite->proxy($proxy)->on_fault(sub{});
  27. print STDERR "Usage: method[(parameters)]\n> ";
  28. while (defined($_ = shift || <>)) {
  29.   next unless /\w/;
  30.   my($method, $parameters) = /^\s*([.\w]+)(.*)/;
  31.   $can{$method} = $xmlrpc->can($method) unless exists $can{$method};
  32.   my $res = $method =~ /\./ ? eval "\$xmlrpc->call(\$method, $parameters)" : eval "\$xmlrpc->$_";
  33.   $@                               ? print(STDERR join "\n", "--- SYNTAX ERROR ---", $@, '') :
  34.   $can{$method} && !UNIVERSAL::isa($res => 'XMLRPC::SOM')
  35.                                    ? print(STDERR join "\n", "--- METHOD RESULT ---", $res || '', '') :
  36.   defined($res) && $res->fault     ? print(STDERR join "\n", "--- XMLRPC FAULT ---", @{$res->fault}{'faultCode', 'faultString'}, '') :
  37.   !$xmlrpc->transport->is_success  ? print(STDERR join "\n", "--- TRANSPORT ERROR ---", $xmlrpc->transport->status, '') :
  38.                                      print(STDERR join "\n", "--- XMLRPC RESULT ---", Dumper($res->paramsall), '')
  39. } continue {
  40.   print STDERR "\n> ";
  41. }
  42.  
  43. __END__
  44.  
  45. =head1 NAME
  46.  
  47. XMLRPCsh.pl - Interactive shell for XMLRPC calls
  48.  
  49. =head1 SYNOPSIS
  50.  
  51.   perl XMLRPCsh.pl http://betty.userland.com/RPC2 
  52.   > examples.getStateName(2)
  53.   > examples.getStateNames(1,2,3,7)
  54.   > examples.getStateList([1,9])
  55.   > examples.getStateStruct({a=>1, b=>24})
  56.   > Ctrl-D (Ctrl-Z on Windows)
  57.  
  58. or
  59.  
  60.   # all parameters after uri will be executed as methods
  61.   perl XMLRPCsh.pl http://betty.userland.com/RPC2 examples.getStateName(2)
  62.   > Ctrl-D (Ctrl-Z on Windows)
  63.  
  64. =head1 DESCRIPTION
  65.  
  66. XMLRPCsh.pl is a shell for making XMLRPC calls. It takes one parameter,
  67. endpoint (actually it will tell you about it if you try to run it). 
  68. Additional commands can follow.
  69.  
  70. After that you'll be able to run any methods of XMLRPC::Lite, like autotype, 
  71. readable, etc. You can run it the same way as you do it in 
  72. your Perl script. You'll see output from method, result of XMLRPC call,
  73. detailed info on XMLRPC faulure or transport error.
  74.  
  75. For full list of available methods see documentation for XMLRPC::Lite.
  76.  
  77. Along with methods of XMLRPC::Lite you'll be able (and that's much more 
  78. interesting) run any XMLRPC methods you know about on remote server and
  79. see processed results. You can even switch on debugging (with call 
  80. something like: C<on_debug(sub{print@_})>) and see XMLRPC code with 
  81. headers sent and recieved.
  82.  
  83. =head1 COPYRIGHT
  84.  
  85. Copyright (C) 2000 Paul Kulchenko. All rights reserved.
  86.  
  87. =head1 AUTHOR
  88.  
  89. Paul Kulchenko (paulclinger@yahoo.com)
  90.  
  91. =cut
  92.  
  93. __END__
  94. :endofperl
  95.